In the context of microprocessors, a speculative execution system (SES) is a system that enables the speculative execution of instructions. Speculative execution is typically leveraged to enable safe execution of dynamically optimized code (e.g., execution of optimized regions of code in a hardware (HW) and/or software (SW) co-designed systems). The data produced by the speculative execution of instructions is typically referred to as speculative data. To ensure correct execution, the system may protect the current architectural state (e.g., the state visible by the user) by keeping it unmodified during the speculative execution of instructions.
If the speculative execution is incorrect, the SES discards the speculative data and makes one or more attempts to re-execute the instructions again. In some circumstances, additional attempts to re-execute the instructions occur by way of a more conservative approach (e.g., via a non-speculative execution of instructions, via a smaller degree of speculation in the execution, etc.). On the other hand, in the event that the speculative execution is proven correct, the SES may convert the speculative execution into a non-speculative execution, thereby changing the architectural state. This may be done by promoting the speculative data to non-speculative data.